home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / util / misc / Fudgit233.lha / Source / examples / fft.ft < prev    next >
Encoding:
Text File  |  1993-12-14  |  1.5 KB  |  53 lines

  1. # Show how padding affects results on fft
  2. # Tell gnuplot our specifications
  3. pmode clear; set data style line; set nolog
  4. # Define a few macros for the sake of it
  5. macro dofft 2
  6.     # Append _FT to the name of transformed vectors.
  7.     fft $1 $2 $1_FT $2_FT
  8.     let POW$1 = ($1_FT^2 + $2_FT^2)
  9. stop
  10. macro doinvfft 2
  11.     # Append _IFT to the name of inverse tranformed vectors.
  12.     invfft $1 $2 $1_IFT $2_IFT
  13.     let POW$1 = ($1_IFT^2 + $2_IFT^2)
  14. stop
  15. # Take the next power of 2 larger than 700.
  16. set data 1024
  17. # Generate an identity permutation
  18. let n=0 ; N=n++
  19. let IM=0
  20. let x=0 ; X = (x++ * 2 * pi/data)
  21. # A will be created with 1024 so it will be
  22. # filled with zeros from 700 to 1024.
  23. let A=0
  24. set data 700
  25. let A=cos(100*X) + sin(100*X) + cos(10*X) + sin(10*X)
  26. # Go back to 1024 to do the fft.
  27. set data 1024
  28. echo Plotting function...
  29. echo Note that it is zero padded from 700 to 1024.
  30. gnu N A
  31. pause -1 "Hit return"
  32. # Do the Fourier transform using our user-defined macro.
  33. dofft A IM 
  34. # Only plot the first half of it.
  35. # Change the `data' constant into a variable.
  36. unlock data
  37. # Let the size of vectors be half for a while since real vectors
  38. # transform in symmetrical frequency functions (f(x) = f(-x)).
  39. let data/=2
  40. echo Plotting the Fourier transform...
  41. gnu N POWA
  42. echo Look how data is affected (shoulders around 10 and 100)
  43. pause -1 "Hit return"
  44. # Go back to original size. 
  45. let data*=2
  46. # Change the `data' variable back to a constant.
  47. lock data
  48. # Do the inverse Fourier transform using our user-defined macro.
  49. doinvfft A_FT IM_FT
  50. echo Plotting real function transformed back...
  51. gnu N A_FT_IFT
  52.  
  53.